<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  scriptList start -->
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>

<script type="text/javascript">
$(document).ready(function(){


	 $("#cancel").click(function(){  
		 
			 
	 	window.location.href="products.php";
			 
	 })
});
</script>
<title>产品中心信息</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="../css/admin/base.css" />
<link rel="stylesheet" type="text/css" href="../css/admin/main.css" />
<style type="text/css">
tr{
	height:40px;
}
input{
	width:500px; 
	background:url(../images/admin/inputbg.gif) repeat-x; 
	border:solid 1px #d1d1d1; 
	font-size:9pt; 
	font-family:Verdana, Geneva, sans-serif;
	
}
</style>
</head>
<body leftmargin="8" topmargin='8'>
<?php


	$id=$_GET['id'];
	$type=$_GET['type'];
   /* echo "<script language='javascript'> alert('$type');</script>"; */
	if($type == "update"){
		require_once("../conn.php"); 
		$sql = "select * from v_app_product where id=".$id;
		$rs = mysql_query($sql);
		while($row=mysql_fetch_array($rs)){
			$encode="utf-8";
			$value = $row["value"];
			$productName=$row["productName"];
			$pictureName=$row["pictureName"];
			$pictureInfo=$row["productInfo"];
			$picc1=$row["ppic1"];
			$picc2=$row["ppic2"];
			/*echo $pictureInfo;*/
		}
	}


	if ($_POST['Submit']!="")
	{

		$id=$_POST['id'];
		$code = $_POST['code'];
		$pic = $_POST['pic'];
		$title = $_POST['title'];
		$type =  $_POST['type'];
		$info =  $_POST['content'];
		$picc1 =  $_POST['pic1'];
		$picc2 =  $_POST['pic2'];
		$date = date( "Y-m-d");
		/* echo "<script language='javascript'> alert('$title');</script>";
		echo "<script language='javascript'> alert('$content');</script>"; 
		echo "<script language='javascript'> alert('$type');</script>"; */
		/*echo "<script language='javascript'> alert('$picc2');</script>"; 
		echo "<script language='javascript'> alert('$type');</script>"; */

		if($type == "update"){
			
			require_once("../conn.php"); 
			$sql="update t_app_product set productName = '".$title."' , pictureName = '".$pic."' ,
					code = '".$code."' , productInfo = '".$info."', ppic1 = '".$picc1."' , ppic2 = '".$picc2."' where id = ".$id;
  
 			mysql_query($sql);

			echo "<script language='javascript'>alert('修改成功!');window.location.href='products.php';</script>";
		}elseif($type == "insert"){

			require_once("../conn.php"); 
			$sql="insert into t_app_product (productName,pictureName,code,productInfo,ppic1,ppic2)
					values( '".$title."' , '".$pic."' , ".$code.", '".$info."', '".$picc1."', '".$picc2."') ";
 			mysql_query($sql);
			echo mysql_error();
			echo "<script language='javascript'>alert('新增成功!');window.location.href='products.php';</script>";


		}

	}
						
?>
<form name="form1" method="post" action="productsedit.php"> 

<table width="98%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px">
  <tr bgcolor="#EEF4EA">
    <td colspan="2" background="../images/admin/wbg.gif" class='title'><span>产品中心信息</span></td>
  </tr>
  <tr bgcolor="#FFFFFF" style="display:none;">
    <td width="25%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='type' id='type' value='".$type."'></input>";
	?>
	</td>
    <td width="75%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='id' id='id' value='".$id."'></input>";
	?>
	</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="25%" bgcolor="#FFFFFF">产品中心：</td>
    <td width="75%" bgcolor="#FFFFFF">
    
    <select name="code">
	    <option value="1" selected="selected">飞利浦家居线缆系列 </option>
	    <option value="2">白蝶管系列  </option>
	    <option value="3">检查井系列  </option>
	    <option value="4">内衬不锈钢管系列  </option>
 	</select>
    
	</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="25%" bgcolor="#FFFFFF">产品标题：</td>
    <td width="75%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='title' id='title' value='".$productName."'></input>";
	?>
	</td>
  </tr>
   <tr bgcolor="#FFFFFF">
    <td width="25%" bgcolor="#FFFFFF">产品图片：</td>
    <td width="75%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='pic' id='pic' value='".$pictureName."'></input>";
		 /*echo $pictureInfo;*/
	?>
	
	
	</td>
  </tr>
   <tr bgcolor="#FFFFFF">
    <td width="25%" bgcolor="#FFFFFF">产品介绍图片1：</td>
    <td width="75%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='pic1' id='pic1' value='".$picc1."'></input>";
		 /*echo $pictureInfo;*/
	?>
	
	
	</td>
  </tr>
   <tr bgcolor="#FFFFFF">
    <td width="25%" bgcolor="#FFFFFF">产品介绍图片2：</td>
    <td width="75%" bgcolor="#FFFFFF">
    <?php
		 echo "<input type='text' name='pic2' id='pic2' value='".$picc2."'></input>";
		 /*echo $pictureInfo;*/
	?>
	
	
	</td>
  </tr>
   <tr>
          <td width="25%" bgcolor="#FFFFFF">产品说明：</div></td>
          <td><input type="hidden" id="content" name="content" style="display:none" value="<?php echo(htmlspecialchars ($pictureInfo));?>" />
          <input type="hidden" id="FCKeditor1___Config" value="" style="display:none" />
          <iframe id="FCKeditor1___Frame" src="../fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Default" width="700" height="300" frameborder="0" scrolling="no"></iframe></td>
        </tr>
  <tr bgcolor="#FFFFFF">
  <td>
  	
	
  </td>
  <td>
  	<input type="submit" name="Submit" id="Submit" value="提交" style="width:50px;"> 
  	<input type="button" name="Cancel" id="cancel" value="返回" style="width:50px;"> 
  </td>
  </tr>
</table>
</form>
</body>
</html>